home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / nwtp06 / clrconn.pas < prev    next >
Pascal/Delphi Source File  |  1996-07-10  |  2KB  |  59 lines

  1. {$X+,B-,V-} {essential compiler directives}
  2.  
  3. Program ClrConn;
  4.  
  5. { Example for the nwServ unit / NwTP 0.6 API. (c) 1993,1995, R.Spronk }
  6.  
  7. { Purpose: Utility for users with console privileges:
  8.            Terminate a connection on the current server. }
  9.  
  10. { Tests the following nwServ functions:
  11.  
  12.   CheckConsolePrivileges
  13.   ClearConnectionNumber
  14. }
  15.  
  16. Uses nwMisc,nwServ;
  17.  
  18. Var errCode:Integer;
  19.     connNbr:byte;
  20.     connStr:String;
  21.     showHelp:boolean;
  22.  
  23. begin
  24.  
  25. IF NOT CheckConsolePrivileges
  26.  then begin
  27.       IF nwServ.result=$C6
  28.        then writeln('You need console privileges to run this util.')
  29.        else writeln('Error checking console privileges, err#',nwServ.result);
  30.       halt(1);
  31.       end;
  32.  
  33. IF ParamCount=1
  34.  then begin
  35.       connStr:=ParamStr(1);
  36.       Val(connStr,connNbr,errCode);
  37.       showhelp:=(errCode<>0);
  38.       end
  39.  else showHelp:=true;
  40.  
  41. IF showHelp
  42.  then begin
  43.       writeln('CLRCONN-- usage:');
  44.       writeln;
  45.       writeln('CLRCONN connection_number');
  46.       writeln;
  47.       writeln('the connection_number must be supplied.');
  48.       writeln('it should contain numbers only (range 1..255)');
  49.       halt(1);
  50.       end;
  51. IF ClearConnectionNumber(connNbr)
  52.  then writeln('Connection ',connNbr,' was terminated.')
  53.  else if nwServ.result=253
  54.       then writeln('Connection NOT cleared. The supplied ConnectionNumber was too high.')
  55.       else if nwServ.result=162
  56.            then writeln('You cleared your own connection!')
  57.            else writeln('Connection NOT cleared. Error# ',nwServ.result);
  58.  
  59. end.